package com.yiwise.config;

import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class MDCDecoratedServlet extends DispatcherServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        NewMDCDecoratorCallable decoratorCallable = new NewMDCDecoratorCallable(() -> {
            super.service(request, response);
            return null;
        });
        try {
            decoratorCallable.call();
        } catch (ServletException | IOException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
